import requests


class DepApi:

    # 封装部门接口
    # 添加部门
    @classmethod
    def add_dep(cls, token, body):
        url = "http://ihrm2-test.itheima.net/api/company/department"
        head = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.post(url=url, headers=head, json=body)
        return resp

    # 修改部门
    @classmethod
    def update_dep(cls, dep_id, token, body):
        url = f"http://ihrm2-test.itheima.net/api/company/department/{dep_id}"
        head = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.put(url=url, headers=head, json=body)
        return resp

    # 部门查看
    @classmethod
    def query_dep(cls, dep_id, token):
        url = f"http://ihrm2-test.itheima.net/api/company/department/{dep_id}"
        head = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.get(url=url, headers=head)
        return resp

    # 删除部门
    @classmethod
    def delete_dep(cls, dep_id, token):
        url = f"http://ihrm2-test.itheima.net/api/company/department/{dep_id}"
        head = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.delete(url=url, headers=head)
        return resp
